<?php

/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 7.3    TS-Frame                                          |
// +----------------------------------------------------------------------+
// | Copyright (c) 2019-2021 ©TS-Frame                                    |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Original Author <haoge985@qq.com>                           |
// |          Your Name <ts-frame>                                        |
// +----------------------------------------------------------------------+
require __DIR__ . '/vendor/autoload.php';


//容器核心
//bind方法注册一个绑定 非单例
//instance方法将已存在的对象绑定到容器中
//singleton方法绑定一个只需要解析一次的类或接口到容器，然后接下来对容器的调用将会返回同一个实例
//Laravel容器类调用make方法时，如果没有已注册的key,那么会自动通过反射类实例化具体类
$app = new Utils\Application(); // 服务容器启动！！！

$app->singleton(\Utils\Mapper::class); //单例绑定至闭包方法 通过内存访问速度快!!!

//框架核心
$URI =array_reverse(explode("/", $_SERVER['REQUEST_URI']));//兼容 web.config 服务器 和  .htaccess 本地写法！
$className = $URI[1];
$methodName = explode("?",$URI[0])[0];
//$app->__set('api',$className);//缓存控制层名字
$class = 'Api\\' . $className;
!class_exists($class) && print_r('控制器不存在！') && exit();
$app->singleton($class);//单例绑定控制器
$app->make($class)->$methodName($class);
